package org.apache.flink

import org.apache.flink.api.scala._
import org.apache.flink.streaming.api.scala.{DataStream, StreamExecutionEnvironment}

object TaskSubTaskApp {

    def main(args: Array[String]): Unit = {

       val env: StreamExecutionEnvironment = StreamExecutionEnvironment.getExecutionEnvironment

        val stream: DataStream[String] = env.socketTextStream("hadoop000", 9999)

        println(stream.parallelism)

        stream.flatMap(_.split(",")).uid("12345").name("flatmap_split")
          .filter(!_.startsWith("a"))
          .map((_,1))
          .keyBy(0)  // shuffle
          .sum(1)
          .print()

        env.execute(this.getClass.getSimpleName)
    }
}
